{block name=head}
<style type="text/css">

</style>
{/block}

{block name=body}
<div id="partycont">
    <div class="container">
        <div class="row">
            <div class="col-sm-{if $listing_image}8{else}12{/if}">
                <div class="visible-md visible-lg">
                    {include file='breadcrumbs.tpl'} 
                </div>
            </div>
        </div>
    </div>
</div>

<div class="container pagecont">
    <div class="row">
        {if $payment}
        <div class="col-sm-8 col-sm-offset-2">
            <div class="row order">
                <div class="pull-left">
                    <strong>
                    请您及时付款，以便订单尽快处理！订单号：{$payment.payment_transaction_no}
                    </strong>
                    <div class="tips" style="line-height: 20px;height: 20px;">
                    </div>
                </div>
                <div class="pull-right">
                    <div class="price">
                        <span>应付金额</span> <strong style="color: #ff5d5b">{$payment.payment_total}</strong> <span>元</span>
                    </div>
                    <a class="btn btn-link" type="button" data-toggle="collapse" data-target="#paydetail" aria-expanded="false" aria-controls="paydetail" style="text-decoration:none">
                    订单详情 <span class="glyphicon glyphicon-menu-down" aria-hidden="true"></span></a>
                </div>
                <div class="clr"></div>
                <div class="list j_orderList" id="listPayOrderInfo" style="display: block;clear: both">
                    <div class="collapse" id="paydetail">
                        <div class="" style="">
                            <!-- 单笔订单 -->
                            <div class="" style="font-size: 14px;padding:20px 0;border-top: 1px solid #ddd;">
                                <span style="margin-right: 10px">收货地址：{$payment.shipping.address_state} {$payment.shipping.address_suburb} {$payment.shipping.address_country} {$payment.shipping.address_line1}</span>
                                <span style="margin-right: 10px">收货人：{$payment.shipping.address_name} {$payment.shipping.address_surname}</span>
                                <span id="mobile">{$payment.shipping.address_telephone}</span><br />
                                <span>商品名称：
                                {foreach $payment.items as $item}
                                {$item.cartitem_product_name}，
                                {/foreach}</span>
                            </div>
                            <!-- 单笔订单 end -->
                        </div>
                    </div>
                </div>
            </div>
            <div class="row payment">
                {if $pmethod=='wx'}
                    <!-- 微信支付 -->
                    <div class="pay-weixin">
                        <div class="p-w-hd">
                        <strong>微信支付</strong>
                        <input type="hidden" name="trade_no" value="{$tradeno}" id="out_trade_no">
                        </div>
                        <div class="p-w-bd" style="position:relative;">
                            <!-- <div class="" style="position:absolute; top: -26px; left: 130px;color:#ff5d5b;font-size:14px">二维码已过期，<a href="javascript:getWeixinImage();">刷新</a>页面重新获取二维码。</div> -->
                            <div class="pull-left" style="width: 300px;margin-left:100px">
                                <div class="pw-box-hd" style="margin-bottom: 20px;border: 1px solid #ddd;width: 298px;height: 298px;">
                                    <img id="weixinImageURL" src="/qrcode?data={$url}" width="298" height="298">
                                </div>
                                <div class="pw-retry j_weixiRetry" style="display: none;">
                                    <a class="ui-button ui-button-gray j_weixiRetryButton" href="javascript:getWeixinImage();">获取失败 点击重新获取二维码  </a>
                                </div>
                                <div class="pw-box-ft" style="color: #fff;font-size: 14px;height: 60px;padding: 8px 0 8px 125px;background: url(/images/icon-red.png) 50px 8px no-repeat #ff7674;">
                                    <small>请使用微信扫一扫</small><br />
                                    <small>扫描二维码支付</small>
                                </div>
                            </div>
                            <div class="p-w-sidebar" style="float: left;width: 379px;height: 421px;padding-left: 50px;margin-top: -20px;background: url(/images/phone-bg.png) 50px 0 no-repeat;"></div>
                        </div>
                    </div>
                    <!-- 微信支付 end -->
                {elseif $pmethod=='al'}
                    <!-- 支付宝 -->
                    <div class="pay-weixin">
                        <div class="p-w-hd">
                            <strong>支付宝支付</strong>
                            <input type="hidden" name="trade_no" value="{$tradeno}" id="out_trade_no">
                        </div>
                        <div class="p-w-bd" style="position:relative;">
                            <!-- <div class="" style="position:absolute; top: -26px; left: 130px;color:#ff5d5b;font-size:14px">二维码已过期，<a href="javascript:getWeixinImage();">刷新</a>页面重新获取二维码。</div> -->
                            <div class="pull-left" style="width: 300px;margin-left:100px">
                                <div class="pw-box-hd" id="alipayQRcode" style="margin-bottom: 20px;border: 1px solid #ddd;width: 298px;height: 298px;">
                                    {*{$qrcode}*}
                                    <img id="alipayImageURL" src="/qrcode?data={$url}" width="298" height="298">
                                </div>
                                <div class="pw-retry j_weixiRetry" style="display: none;">
                                    <a class="ui-button ui-button-gray j_weixiRetryButton" href="javascript:getWeixinImage();">获取失败 点击重新获取二维码  </a>
                                </div>
                                <div class="pw-box-ft" style="color: #fff;font-size: 14px;height: 60px;padding: 8px 0 8px 125px;background: url(/images/icon-red.png) 50px 8px no-repeat #ff7674;">
                                    <small>请使用支付宝扫一扫</small><br />
                                    <small>扫描二维码支付</small>
                                </div>
                            </div>
                            <div class="p-w-sidebar" style="float: left;width: 379px;height: 421px;padding-left: 50px;margin-top: -20px;background: url(/images/alipay_demo.jpg) 50px 0 no-repeat;"></div>
                        </div>
                    </div>
                    <!-- 支付宝 end -->
                {/if}

                <!-- payment-change 变更支付方式 -->
                <div class="payment-change" style="clear: both">
                    <a class="pc-wrap" id="reChooseUrl" href="/shopping-cart">
                        <i class="pc-w-arrow-left">&lt;</i>
                        <strong>选择其他支付方式</strong>
                    </a>
                </div>
                <!-- payment-change 变更支付方式 end -->
            </div>
        </div>
        {else}
        <div class="col-sm-8 col-sm-offset-2">
            <div class="jumbotron" style="">
                <h2><span class="glyphicon glyphicon-exclamation-sign"></span> 您的订单状态错误！</h2>
                <p>您的订单存在安全风险，请查看订单状态或稍后重试。</p>
                <div class="" style="padding-top:30px">
                    <a class="green-btn" href="/my-account">重新支付</a>
                </div>
            </div>
        </div>
        {/if}
    </div>
</div>

{/block}

{* Place additional javascript here so that it runs after General JS includes *}
{block name=tail}

<script type="text/javascript">
//    $("#alipayQRcode img").width("298px").height("298px");
jQuery(document).ready(function($){
    setInterval("ajaxstatus()", 3000);
});

function ajaxstatus() {
    if ($("#out_trade_no").val()) {
        $.ajax({
            url: "/process/cart",
            type: "POST",
            dataType:"json",
            data: "action=getPaymentStatus&orderno="+$("#out_trade_no").val(),
            success: function (data) {
                if (data.status=='A') { //订单状态为1表示支付成功
                   window.location.href = "/checkout-completed"; //页面跳转
                }
            }
        });
    }
}
</script>
{/block}
